/**
 ********************************************************************
 * @author roocket
 * @file    user.c
 * @version V0.0.0
 * @date    2024/3/22
 * @brief   This file is to indicate user functions. 
 * @attention Code file rules:
 * rule: file encoding use UTF8;
 * rule: max line length 120 characters;
 * rule: line separator \r\n;
 * rule: use clion auto code format tool.
 */
#include "user.h"

int user_video_entry_get_bulks(struct user_video_structure *user_vs)
{
    int fd = -1;
    int ret = -1;

    struct video_compatible_info vfo = {0};

    vfo.width = user_vs->pix_width;
    vfo.height = user_vs->pix_height;
    vfo.pixel_format = user_vs->pix_fmt;

    fd = video_init(user_vs->video_device, &vfo);
    if (-1 == fd) {
        perror("fail init video");
        return -1;
    }

    video_be_capturing(&vfo);

    #if 0
    video_get_one_image("/tmp", fd, &vfo, 0);
    #endif

    ret = video_get_bulk_images(user_vs->directory, fd, &vfo, user_vs->bulks_of_videos);
    if (-1 == ret) {
        printf("get bulk images fail\n");
        goto free_vd;
    }

    return 0;   
free_vd:
    video_del(fd, &vfo);
    return -1;
}

